package com.jindu.producer.system.controller;

import com.jindu.kernel.result.JsonResult;
import com.jindu.kernel.result.StatusCode;
import com.jindu.producer.system.config.QiNiuToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @author jarvis
 * @date 2018/2/21
 */
@Api(description = "公共的工具类", tags = "UtilsController", basePath = "/utils")
@RestController
@RequestMapping(value = "/utils",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class UtilsController {

    @Resource
    QiNiuToken qiNiuToken;

    @ApiOperation(value = "获取七牛云的token", notes = "获取七牛云的token")
    @RequestMapping(value = "getQiniuToken", method = RequestMethod.GET)
    public JsonResult<String> getQiniuToken(){
        return JsonResult.getSuccessResult(qiNiuToken.getQiniuToken());
    }

    @RequestMapping(value = "tokenTimeOut", method = RequestMethod.GET)
    public JsonResult<HashMap<String,Object>> tokenTimeOut(){

        HashMap<String,Object> message=new HashMap<>();
        message.put("statusCode",StatusCode.TokenTimeOut.getCode().toString());
        message.put("statusMessage",StatusCode.TokenTimeOut.getMeaning());

        return JsonResult.getFailureResult(StatusCode.INVALID_REQUEST,message);
    }


}
